package util;
import java.util.ResourceBundle;

/**
 * Class that allows easy access to configuration parameters
 * that are loaded from a configuration file called
 * "config.properties" in the project root directory.
 * @author Jan
 */
public class ConfigFile {

	private static final ResourceBundle _bundle =
		ResourceBundle.getBundle("config");
	
	/**
	 * Attempt to load a String from the config file.
	 * @param key The key the String is stored under
	 * @return The stored String
	 */
	public static String getString(String key) {
		return _bundle.getString(key);
	}
	
	/**
	 * Attempt to load an int value from the config file.
	 * @param key The key the int is stored under
	 * @return The stored int
	 */
	public static int getInt(String key) {
		return Integer.valueOf(getString(key));		
	}

	/**
	 * Attempt to load a float value from the config file.
	 * @param key The key the float is stored under
	 * @return The stored float
	 */
	public static float getFloat(String key) {
		return Float.valueOf(getString(key));
	}
	
	/**
	 * Attempt to load a boolean value from the config file.
	 * @param key The key the boolean is stored under
	 * @return The stored boolean
	 */
	public static boolean getBoolean(String key){
		return Boolean.valueOf(getString(key));
	}
	
	public static void main(String[] args) {
		//System.out.println("int: " + ConfigFile.getInt("test"));
		if(ConfigFile.getBoolean("testeboolean")){
			System.out.println("String: " + ConfigFile.getString("testeboolean"));
		}
		//System.out.println("float: " + ConfigFile.getFloat("test.floatvalue"));
	}

}
